package com.ruoyi.apartment.controller;

import com.ruoyi.apartment.domain.Province;
import com.ruoyi.apartment.domain.City;
import com.ruoyi.apartment.service.IProvinceService;
import com.ruoyi.apartment.service.ICityService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/apartment/region")
public class RegionController extends BaseController {
    @Autowired
    private IProvinceService provinceService;

    @Autowired
    private ICityService cityService;

    @GetMapping("/provinces")
    public AjaxResult getProvinceList(Province province) {
        return AjaxResult.success(provinceService.selectProvinceList(province));
    }

    @GetMapping("/cities")
    public AjaxResult getCityList(City city) {
        return AjaxResult.success(cityService.selectCityList(city));
    }

    @GetMapping("/cities/{provinceId}")
    public AjaxResult getCitiesByProvinceId(@PathVariable Long provinceId) {
        return AjaxResult.success(cityService.selectCityListByProvinceId(provinceId));
    }
}